package com.haimi.shiguang.utils;

import com.haimi.shiguang.base.biz.SequenceTypeEnum;

import java.util.UUID;

/**
 * @Author: Panyuanyuan
 * @Date: Created in 下午10:42 2018/6/5
 * @Description:
 */
public class SequenceUtil {

    /**
     * 序列号随机数长度
     */
    private static final Integer SQE_NO_UUID_SIZE = 15;

    /**
     * 业务序列号生成器
     *
     * @param sequenceType
     * @return
     */
    public static String getSequenceNo(SequenceTypeEnum sequenceType) {
        if (sequenceType == null) {
            return "";
        }
        String formatTime = DateTimeUtil.getCurrentDateTime(DateTimeUtil.DATE_YYYYMMDDHHMMSSSSS);
        String uuidSeq = UUID.randomUUID().toString().replace("-", "").substring(0, SQE_NO_UUID_SIZE);
        return sequenceType.getValue() + formatTime + uuidSeq;
    }
}